# coding:utf-8
import os
import sys

from PySide6.QtCore import Qt, QTranslator, QLocale
from PySide6.QtWidgets import QApplication
from qfluentwidgets import FluentTranslator

from common import cfg, exception_hook
from views import MainWindow

# enable dpi scale
if cfg.get(cfg.dpiScale) != "Auto":
    os.environ["QT_ENABLE_HIGHDPI_SCALING"] = "0"
    os.environ["QT_SCALE_FACTOR"] = str(cfg.get(cfg.dpiScale))

sys.excepthook = exception_hook
# create application
app = QApplication(sys.argv)
app.setAttribute(Qt.ApplicationAttribute.AA_DontCreateNativeWidgetSiblings)

# internationalization
locale = QLocale(QLocale.Language.Chinese, QLocale.Country.China)
translator = FluentTranslator(locale)
galleryTranslator = QTranslator()
app.installTranslator(translator)

w = MainWindow()
w.show()
app.exec()
